********************************************************************************
* Figure A.2: Comparison of official turnout data and survey turnout data
********************************************************************************

use  "Data_temp/turnout.dta", clear


collapse (mean) voted=voted (sem) sd=voted if age0>0, by(election)
gen ci_lo=voted-1.96*sd
gen ci_up=voted+1.96*sd

foreach var in voted ci_l ci_u {
    replace `var'=`var'*100
	}

* Manually add election turnout data from ONS	
gen actual=.
replace actual =77.7 if election==1992 
replace actual =71.3 if election==1997 
replace actual =59.4 if election==2001 
replace actual =61.4 if election==2005 
replace actual =65.1 if election==2010 
replace actual =66.4 if election==2015 
replace actual =68.8 if election==2017 
replace actual =67.3 if election==2019 

gen diff=actual-voted

twoway (scatter actual election, mcolor(black) msize(large)) ///
		(scatter voted election, msymbol(Th) mlcolor(black) msize(large)), ///
		xlab(1992 "1992" "1997" 2001 "2001" 2005 "2005" 2010 "2010" 2015 "2015" 2017 "2017") ///
		ylab(40(10)90) yt("Turnout in %") legend(order(1 "Official turnout" 2 "Turnout in survey data")) ///
		xt("Election") graphregion(margin(zero)) xsc(r(1991 2018)) ///
		yline(40 50 60 70 80 90, lcolor(gs15) lpattern(dash))
graph export "Figures/a_fg2.eps", replace